<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/factory/CommandFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	
	class PresenterCreateUser {
		
		public function __construct() {}
		
		public function clickCreateUser ($user) {
									
			
			$command = CommandFactory :: createCommandCreateUser ($user['userName'],$user['password'],$user['firstName'],$user['secondName'],$user['firstLastName'],$user['secondLastName'],$user['emailAddress'],$user['role']);
			
			$command -> execute();		
			
			return $command->getResult();
		
		}	
		
		/**
		 * Method to execute to select Users
		 */
		public function selectUsers() {
			$command = CommandFactory :: createCommandSelectUsers();
			$command -> execute();
			$users = $command -> getResult();
			
			$result = '<table class="formTable" cellspacing="0" cellpadding="5">';
			$result .= '<tr class="odd">';
			$result .= '<td align="center"><b>Nombre de Usuario</b></td>';
			$result .= '<td align="center"><b>Primer Nombre</b></td>';
			$result .= '<td align="center"><b>Segundo Nombre</b></td>';
			$result .= '<td align="center"><b>Primer Apellido</b></td>';
			$result .= '<td align="center"><b>Segundo apellido</b></td>';
			$result .= '<td align="center"><b>Correo Electronico</b></td>';
			$result .= '</tr>';
			$i = 0; $unread = 0;
			while ($i < count($users['pk_username'])) {
				if ($i % 2 == 0) $result .= '<tr class="even">';
				else $result .= '<tr class="odd">';
				
				$result .= '<td align="center">' . $users['pk_username'][$i] . '</td>';
				$result .= '<td align="center">' . $users['first_name'][$i] . '</td>';
				$result .= '<td align="center">' . $users['second_name'][$i] . '</td>';
				$result .= '<td align="center">' . $users['first_last_name'][$i] . '</td>';
				$result .= '<td align="center">' . $users['second_last_name'][$i] . '</td>';
				$result .= '<td align="center">' . $users['email_address'][$i++] . '</td>';
			

				$result .= '</tr>';
			}
			
		
				$GLOBALS['debug']->log('Funcion que llama al COMANDO');
		
			return $result;
		}
		
		
		
		
		
		
		
		
		
		
		
		
	}
?>